package com.ubxtech.core.exception;

/**
 * 
 * 功能说明： 自定义异常
 * 
 * RRException.java
 * 
 * Original Author: steven.liang,2017年9月9日上午9:42:39
 * 
 * Copyright (C)2012-2017 深圳优必选科技 All rights reserved.
 */
public class RRException extends RuntimeException {
	private static final long serialVersionUID = 1L;
	
    private String msg;
    private int code = 500;
    /**
     * 错误信息加一个数据字段,可以在全局处理那里返回数据
    */
    private Object data;
    
    public RRException(String msg) {
		super(msg);
		this.msg = msg;
	}

	public RRException(ErrorCode errorCodeEnum) {
		super(errorCodeEnum.getMessage());
		this.msg = errorCodeEnum.getMessage();
		this.code = errorCodeEnum.getCode();
	}


	public RRException(ErrorCode errorCodeEnum,Object errorData) {
		super(errorCodeEnum.getMessage());
		this.msg = errorCodeEnum.getMessage();
		this.code = errorCodeEnum.getCode();
		this.data = errorData;
	}
	public RRException(String msg, int code,Object errorData) {
		super(msg);
		this.msg = msg;
		this.code = code;
		this.data = errorData;
	}

	public RRException(String msg, Throwable e) {
		super(msg, e);
		this.msg = msg;
	}
	
	public RRException(String msg, int code) {
		super(msg);
		this.msg = msg;
		this.code = code;
	}
	
	public RRException(String msg, int code, Throwable e) {
		super(msg, e);
		this.msg = msg;
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}
}
